<%@page contentType="text/html; charset=euc-kr" %>
<%@page import="org.springframework.web.util.WebUtils" %>  
<%@page import="java.io.*" %>  

    <%
       String filename=(String)request.getAttribute("tablename");
       System.out.println(filename+"|g");
       String saveFileName=filename+".xls";
       String path = WebUtils.getRealPath(request.getSession().getServletContext(), "/isbnfile");
	   String excelPath=path + File.separator + saveFileName;
	   File file=new File(excelPath);
	   saveFileName = java.net.URLEncoder.encode(saveFileName, "utf-8");
		response.setContentLength((int) file.length()); 
		response.setContentType("application/octet-stream"); 
		response.setHeader("Content-Disposition", "attachment; filename=\"" + saveFileName + "\"");
		response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache");
	   
	   byte[] bytestream=new byte[(int)file.length()];
		FileInputStream fis=new FileInputStream(file);
		int i=0;
		int j=0;
		while((i=fis.read())!=-1){
		  bytestream[j]=(byte)i;
		  j++;
		}
		fis.close();
 
        out.clear();
        pageContext.pushBody();
        OutputStream outter=response.getOutputStream();
		//PrintWriter out = response.getWriter();   
		outter.write(bytestream);		
		outter.close();
		file.delete();		
    %>
